/*
 * Copyright 2009 Colin Prinn
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */

package net.recursv.motific.at;

import net.recursv.motific.at.command.AtCommand;
import net.recursv.motific.at.runner.AtScript;
import net.recursv.motific.at.runner.AtScriptObserver;

/**
 * Created by: recursv
 * Date: 9/08/2009
 * Time: 1:17:54 AM
 */
class ResultHandler implements AtScriptObserver {
    private static final String PASSED = "Passed: ";
    private static final String FAILED = "Failed at ";
    private static final String COMPLETED = "Completed: ";
    private static final String STARTING = "Starting: ";
    private static final String END_OF_TESTING = "End of testing.";

    public void notifySuccess(AtCommand command) {
        System.out.println(PASSED + command.toString());
    }

    public void notifyFailed(AtCommand command, Throwable error) {
        if (!(error instanceof AtException))
            error.printStackTrace();
        else
            System.out.println(FAILED + error.getMessage());
    }

    public void notifyComplete(AtScript script) {
        System.out.println(COMPLETED + script.getTitle());
        System.out.println();
    }

    public void notifyStarting(AtScript script) {
        System.out.println(STARTING + script.getTitle());
    }
}
